package com.xunyji.demo02weixinauthorization.repository;

import com.xunyji.demo02weixinauthorization.model.weixin.UserBindDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author AltEnter
 * @create 2019-01-13 14:39
 * @desc 微信用户和网站用户绑定持久层接口
 **/
public interface UserBindRepository extends JpaRepository<UserBindDO, Integer> {
    UserBindDO findByOpenid(String openid);

    @Transactional(timeout = 10)
    @Modifying
    @Query("update UserBindDO set password = :password where openid = :openid")
    Integer updatePasswordByOpenid(@Param("password") String password, @Param("openid") String openid);
}
